﻿
namespace System.Collections.Generic
{
    public static class IEnumerableExt
    {
        public static List<T> ToListExt<T>(this IEnumerable<IEnumerable<T>> list)
        {
            var result = new List<T>();
            foreach (var item in list)
                result.AddRange(item);
            return result;
        }
        public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            HashSet<TKey> seenKeys = new HashSet<TKey>();
            foreach (TSource element in source)
            {
                if (seenKeys.Add(keySelector(element)))
                {
                    yield return element;
                }
            }
        }
    }
}
